package com.his.dictitem.service.Imp;

import com.his.dictitem.dao.DictItemMedicineMapper;
import com.his.dictitem.entity.DictItemMedicine;
import com.his.dictitem.service.DictItemMedicineService;
import com.his.dictitem.vo.DictItemMedicineVo;
import com.his.login.entity.DictEmployee;
import com.xiao.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class DictItemMedicineServiceImpl implements DictItemMedicineService {

    @Autowired
    private DictItemMedicineMapper dictItemMedicineMapper;

    @Override
    public void insert(DictEmployee dictEmployee,DictItemMedicineVo dictItemMedicineVo) {
        DictItemMedicine dictItemMedicine=BeanUtil.copyBean(dictItemMedicineVo, DictItemMedicine.class);
        dictItemMedicine.setCreaterId(dictEmployee.getEMPID());
        dictItemMedicine.setCreaterName(dictEmployee.getEMPNAME());
        dictItemMedicine.setCreateTime(new Date());
        dictItemMedicineMapper.insert(dictItemMedicine);
    }

    @Override
    public void updateItemMedicine(DictEmployee dictEmployee,DictItemMedicineVo dictItemMedicineVo) {
        DictItemMedicine dictItemMedicine=BeanUtil.copyBean(dictItemMedicineVo, DictItemMedicine.class);
        dictItemMedicine.setUpdaterId(dictEmployee.getEMPID());
        dictItemMedicine.setUpdaterName(dictEmployee.getEMPNAME());
        dictItemMedicine.setUpdateTime(new Date());
        dictItemMedicineMapper.updateByPrimaryKeySelective(dictItemMedicine);
    }
}
